// pages/logincode/logincode.js
Page({
  
  /**
   * 页面的初始数据
   */
  data: {
    number:"",
    Length:4,    //输入框个数 
    isFocus:true,  //聚焦 
    Value:"",    //输入的内容 
    ispassword:false, //是否密文显示 true为密文， false为明文。 
   
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //通过setData
    this.setData({
       number:options.MobileNumber
    })
  },

  Focus(e){ 
    var that = this; 
    console.log(e.detail.value); 
    var inputValue = e.detail.value; 
    that.setData({ 
       Value:inputValue, 
    }) 
   }, 
  Tap(){ 
    var that = this; 
    that.setData({ 
     isFocus:true, 
    }) 
   }, 


  loginCodeClick:function (e) {

    var checkcode = this.data.Value
    console.log("xxxx"+checkcode)
    if(checkcode != null && checkcode != "" && checkcode != 'undefined')
    {
      wx.request({
        url: 'https://shop1.mollyfantasy.universal-space.cn/p14/app/member/login',
        data: {
          "countryCode":86,
          "mobile":this.data.number,
          "checkcode":checkcode
        },
        method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
        header: {
           'content-type': 'application/x-www-form-urlencoded' 
        }, // 设置请求的 header
        success: function(result){
  
         
          wx.setStorageSync("utoken", result.data.data.access)
          console.log("保存成功"+result.data.data.access)
            wx.switchTab({
              url: '/pages/game/game',
              success: function(res){
                
  
              },
              fail: function() {
              },
              complete: function() {
              }
            })
        },
        fail: function() {
          // fail
        },
        complete: function() {
          // complete
        }
      })

    }else {
      
      wx.showToast({
        title: '请输入验证码',
        duration: 1000
      })
      
    }

  },


  backClick:function(){
      wx.redirectTo({
        url : "/pages/login/login"
      })
  }

})